package com.example.mooctao;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.FragmentTransaction;
import androidx.viewpager2.widget.ViewPager2;

import com.example.mooctao.fragment.CodeFragment;
import com.example.mooctao.fragment.PasswordFragment;
import com.example.mooctao.util.MyPagerAdapter;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
//登录界面
public class UloginActivity extends AppCompatActivity {

  private TabLayout tabLayout;
  private ViewPager2 viewPager;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ulogin);
        tabLayout=findViewById(R.id.tabLayout);
        viewPager=findViewById(R.id.viewPager);
        findViewById(R.id.back_close2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        //设置ViewPager2的适配器，实现页面的切换
        MyPagerAdapter pagerAdapter=new MyPagerAdapter(this);
        viewPager.setAdapter(pagerAdapter);
        //将TabLayout和ViewPager2关联起来
        new TabLayoutMediator(tabLayout, viewPager, new TabLayoutMediator.TabConfigurationStrategy() {
            @Override
            public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
                //设置每个Tab标题
                switch (position){
                    case 0:
                        tab.setText("密码登录");
                        break;
                    case 1:
                        tab.setText("验证码登录");
                        break;

                }
            }
        }).attach();

    }
    }

